/*
 * LanguageHandlerView.java
 *
 * Created on 06 Kasım 2008 Perşembe, 17:27
 */
package org.testis.gui.mvc.view.testdesign;

import org.testis.gui.mvc.view.*;
import org.testis.gui.mvc.controller.testdesign.LanguageHandlerController;
import org.testis.gui.mvc.controller.TestDesignControllerList;
import org.testis.gui.mvc.utilities.TextTransfer;
import org.testis.gui.mvc.utilities.Validatable;
import java.awt.Component;
import java.awt.Frame;
import java.awt.event.WindowListener;
import java.beans.PropertyChangeEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import javax.swing.*;

/**
 *
 * @author  nurhat
 */
public class LanguageHandlerView extends AtofBaseDialog implements
        AbstractViewPanel, Validatable {

    private static final long serialVersionUID = 768567L;
    private String m_windowTitle;
    private HashMap hLanguages;
    private HashMap hDeviceAbstractions;
    private Component myTabs[];

    public LanguageHandlerView(Frame displayFrame,
            boolean modal) {

        super(displayFrame,
                modal);
        m_windowTitle = "Languages";
        initComponents();
        javax.swing.filechooser.FileFilter flt = new javax.swing.filechooser.FileFilter() {

            @Override
            public boolean accept(File f) {
                if (f.isDirectory()) {
                    return true;
                }
                String extension = getExtension(f);
                if (extension != null) {
                    if (extension.equals("lang")) {
                        return true;
                    }
                }
                return false;
            }

            @Override
            public String getDescription() {
                return "Airties Language Files(*.lang)";

            }
        };
        fc.setAcceptAllFileFilterUsed(false);
        fc.setFileFilter(flt);
        myTabs = new Component[tabbedPaneLanguagesView.getTabCount()];
        for (int a = 0; a < tabbedPaneLanguagesView.getTabCount(); a++) {
            myTabs[a] = tabbedPaneLanguagesView.getComponentAt(a);
        }

        tabbedPaneLanguagesView.remove(myTabs[1]);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        fc = new javax.swing.JFileChooser();
        tabbedPaneLanguagesView = new javax.swing.JTabbedPane();
        pnlLanguageList = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        cmbLanguages = new javax.swing.JComboBox();
        btnLoadLanguage = new javax.swing.JButton();
        btnAddLanguage = new javax.swing.JButton();
        btnDeleteLanguage = new javax.swing.JButton();
        btnClose = new javax.swing.JButton();
        pnlAddEditLanguage = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        txtLangName = new javax.swing.JTextField();
        cmbDeviceAbstractions = new javax.swing.JComboBox();
        txtFilePath = new javax.swing.JTextField();
        btnBrowseFile = new javax.swing.JButton();
        btnSave = new javax.swing.JButton();
        fileTxtToClipBoard = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(m_windowTitle);
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel4.setText("Select Language:");

        cmbLanguages.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        btnLoadLanguage.setText("Load");
        btnLoadLanguage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLoadLanguageActionPerformed(evt);
            }
        });

        btnAddLanguage.setText("Add New Language");
        btnAddLanguage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddLanguageActionPerformed(evt);
            }
        });

        btnDeleteLanguage.setText("Delete Selected Language");
        btnDeleteLanguage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteLanguageActionPerformed(evt);
            }
        });

        btnClose.setText("Exit");
        btnClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCloseActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlLanguageListLayout = new javax.swing.GroupLayout(pnlLanguageList);
        pnlLanguageList.setLayout(pnlLanguageListLayout);
        pnlLanguageListLayout.setHorizontalGroup(
            pnlLanguageListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlLanguageListLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cmbLanguages, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnLoadLanguage, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(93, Short.MAX_VALUE))
            .addGroup(pnlLanguageListLayout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addComponent(btnAddLanguage)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnDeleteLanguage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(btnClose)
                .addGap(1173, 1173, 1173))
        );
        pnlLanguageListLayout.setVerticalGroup(
            pnlLanguageListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlLanguageListLayout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(pnlLanguageListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(cmbLanguages, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnLoadLanguage))
                .addGap(84, 84, 84)
                .addGroup(pnlLanguageListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAddLanguage)
                    .addComponent(btnDeleteLanguage)
                    .addComponent(btnClose))
                .addContainerGap(148, Short.MAX_VALUE))
        );

        tabbedPaneLanguagesView.addTab("Languages", pnlLanguageList);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel1.setText("Language Name:(*)");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel2.setText("Device Abstraction :(*)");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel3.setText("Language File:");

        cmbDeviceAbstractions.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        txtFilePath.setEditable(false);

        btnBrowseFile.setText("Browse");
        btnBrowseFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBrowseFileActionPerformed(evt);
            }
        });

        btnSave.setText("Save");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        fileTxtToClipBoard.setText("Click to Copy Language Text To Clipboard");
        fileTxtToClipBoard.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fileTxtToClipBoardActionPerformed(evt);
            }
        });

        btnCancel.setText("Cancel");
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlAddEditLanguageLayout = new javax.swing.GroupLayout(pnlAddEditLanguage);
        pnlAddEditLanguage.setLayout(pnlAddEditLanguageLayout);
        pnlAddEditLanguageLayout.setHorizontalGroup(
            pnlAddEditLanguageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlAddEditLanguageLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlAddEditLanguageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(18, 18, 18)
                .addGroup(pnlAddEditLanguageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtLangName, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pnlAddEditLanguageLayout.createSequentialGroup()
                        .addGroup(pnlAddEditLanguageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(cmbDeviceAbstractions, javax.swing.GroupLayout.Alignment.LEADING, 0, 96, Short.MAX_VALUE)
                            .addComponent(txtFilePath, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 96, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnBrowseFile)))
                .addGap(1236, 1236, 1236))
            .addGroup(pnlAddEditLanguageLayout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addComponent(fileTxtToClipBoard)
                .addGap(18, 18, 18)
                .addComponent(btnSave)
                .addGap(18, 18, 18)
                .addComponent(btnCancel)
                .addContainerGap(62, Short.MAX_VALUE))
        );
        pnlAddEditLanguageLayout.setVerticalGroup(
            pnlAddEditLanguageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlAddEditLanguageLayout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(pnlAddEditLanguageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlAddEditLanguageLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel2)
                        .addGap(14, 14, 14)
                        .addComponent(jLabel3))
                    .addGroup(pnlAddEditLanguageLayout.createSequentialGroup()
                        .addComponent(txtLangName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(14, 14, 14)
                        .addComponent(cmbDeviceAbstractions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlAddEditLanguageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtFilePath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnBrowseFile))))
                .addGap(51, 51, 51)
                .addGroup(pnlAddEditLanguageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(fileTxtToClipBoard)
                    .addComponent(btnSave)
                    .addComponent(btnCancel))
                .addContainerGap(117, Short.MAX_VALUE))
        );

        tabbedPaneLanguagesView.addTab("Add/Edit Language", pnlAddEditLanguage);

        getContentPane().add(tabbedPaneLanguagesView, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 500, 330));

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnBrowseFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBrowseFileActionPerformed

    int returnVal = fc.showOpenDialog(this);

    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        txtFilePath.setText(file.getAbsolutePath());
    }
}//GEN-LAST:event_btnBrowseFileActionPerformed

private void btnAddLanguageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddLanguageActionPerformed
    loadDeviceAbstractions();
    TestDesignControllerList.newInstance().getLanguageHandlerController().
            operationAddLanguage();
    TestDesignControllerList.newInstance().getLanguageHandlerController().
            operationChangeAddVisibility(true);

}//GEN-LAST:event_btnAddLanguageActionPerformed

private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
    TestDesignControllerList.newInstance().getLanguageHandlerController().
            operationCancelSaveLanguage();
    TestDesignControllerList.newInstance().getLanguageHandlerController().
            operationChangeAddVisibility(false);

}//GEN-LAST:event_btnCancelActionPerformed

private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed

    String fileTxt = "";
    if (!txtFilePath.getText().equals("")) {
        try {
            fileTxt = readFile(txtFilePath.getText());
        } catch (FileNotFoundException ex) {
        } catch (IOException ex) {
        }
    }
    Entry entry = (Entry) cmbDeviceAbstractions.getSelectedItem();
    Integer abstractionId = (Integer) entry.getKey();
    TestDesignControllerList.newInstance().getLanguageHandlerController().
            operationSaveLanguage(txtLangName.getText(),
            abstractionId,
            fileTxt);
    txtFilePath.setText("");
    TestDesignControllerList.newInstance().getLanguageHandlerController().
            operationChangeAddVisibility(false);
}//GEN-LAST:event_btnSaveActionPerformed

private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed
    this.setVisible(false);
    this.setEnabled(false);
    this.dispose();
}//GEN-LAST:event_btnCloseActionPerformed

private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
    WindowListener[] listeners = getWindowListeners();
    for (int i = 0; i < listeners.length; i++) {
        this.removeWindowListener(listeners[i]);
    }
    this.setVisible(false);
    this.setEnabled(false);
    TestDesignControllerList.newInstance().getLanguageHandlerController().
            operationCloseWindow();
    this.dispose();
}//GEN-LAST:event_formWindowClosed

private void btnLoadLanguageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadLanguageActionPerformed
    if (cmbLanguages.getSelectedItem() == null) {
        return;
    }
    if (cmbLanguages.getSelectedItem().toString().equals("")) {
        return;
    }
    loadDeviceAbstractions();
    Entry entry = (Entry) cmbLanguages.getSelectedItem();
    int langId = Integer.parseInt(entry.getKey().toString());
    TestDesignControllerList.newInstance().getLanguageHandlerController().
            operationLoadLanguage(langId);
    TestDesignControllerList.newInstance().getLanguageHandlerController().
            operationChangeAddVisibility(true);
    TestDesignControllerList.newInstance().getLanguageHandlerController().
            operationChangeLoadVisibility(false);

}//GEN-LAST:event_btnLoadLanguageActionPerformed

private void btnDeleteLanguageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteLanguageActionPerformed
    if (cmbLanguages.getSelectedItem() == null) {
        return;
    }
    if (cmbLanguages.getSelectedItem().toString().equals("")) {
        return;
    }
    Entry entry = (Entry) cmbLanguages.getSelectedItem();
    int langId = Integer.parseInt(entry.getKey().toString());
    int result =
            javax.swing.JOptionPane.showConfirmDialog(null,
            "Confirmation",
            "Really delete this language?",
            javax.swing.JOptionPane.YES_NO_CANCEL_OPTION,
            javax.swing.JOptionPane.QUESTION_MESSAGE);
    if (result == javax.swing.JOptionPane.YES_OPTION) {

        boolean delResult = TestDesignControllerList.newInstance().
                getLanguageHandlerController().
                operationDeleteLanguage(langId);
        if (!delResult) {
            JOptionPane.showMessageDialog(
                    this,
                    "Unable to delete language...",
                    "Error Dialog",
                    JOptionPane.ERROR_MESSAGE);
        }
        loadLanguages();
    }
}//GEN-LAST:event_btnDeleteLanguageActionPerformed

private void fileTxtToClipBoardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileTxtToClipBoardActionPerformed
    TextTransfer textTransfer = new TextTransfer();
    String fileTxt = TestDesignControllerList.newInstance().
            getLanguageHandlerController().operationGetFileText();
    textTransfer.setClipboardContents(fileTxt);
}//GEN-LAST:event_fileTxtToClipBoardActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddLanguage;
    private javax.swing.JButton btnBrowseFile;
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnClose;
    private javax.swing.JButton btnDeleteLanguage;
    private javax.swing.JButton btnLoadLanguage;
    private javax.swing.JButton btnSave;
    private javax.swing.JComboBox cmbDeviceAbstractions;
    private javax.swing.JComboBox cmbLanguages;
    private javax.swing.JFileChooser fc;
    private javax.swing.JButton fileTxtToClipBoard;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel pnlAddEditLanguage;
    private javax.swing.JPanel pnlLanguageList;
    private javax.swing.JTabbedPane tabbedPaneLanguagesView;
    private javax.swing.JTextField txtFilePath;
    private javax.swing.JTextField txtLangName;
    // End of variables declaration//GEN-END:variables
  /*
     * Get the extension of a file.
     */

    public static String getExtension(File f) {
        String ext = null;
        String s = f.getName();
        int i = s.lastIndexOf('.');

        if (i > 0 && i < s.length() - 1) {
            ext = s.substring(i + 1).toLowerCase();
        }
        return ext;
    }

    private String readFile(String filePath) throws FileNotFoundException,
            IOException {
        FileInputStream fi = new FileInputStream(filePath);
        InputStreamReader is = new InputStreamReader(fi,
                "UTF8");
        BufferedReader in = new BufferedReader(is);
        String s;
        StringBuilder sb = new StringBuilder();
        while ((s = in.readLine()) != null) {
            sb.append(s + "\r\n");
            System.out.println("" + s);
        }
        in.close();
        is.close();
        fi.close();
        return sb.toString();
    }

    private void loadDeviceAbstractions() {

        cmbDeviceAbstractions.removeAllItems();
        cmbDeviceAbstractions.addItem("");
        hDeviceAbstractions = TestDesignControllerList.newInstance().
                getLanguageHandlerController().
                operationGetDeviceAbstractionMap();
        if (hDeviceAbstractions != null) {
            Iterator iter = hDeviceAbstractions.entrySet().
                    iterator();
            while (iter.hasNext()) {
                Map.Entry entry = (Map.Entry) iter.next();
                cmbDeviceAbstractions.addItem(entry);
            }
        }
        cmbDeviceAbstractions.repaint();
        cmbDeviceAbstractions.updateUI();
    }

    private void loadLanguages() {

        cmbLanguages.removeAllItems();
        cmbLanguages.addItem("");
        hLanguages = TestDesignControllerList.newInstance().
                getLanguageHandlerController().
                operationGetLanguageMap();
        if (hLanguages != null) {
            Iterator iter = hLanguages.entrySet().
                    iterator();
            while (iter.hasNext()) {
                Map.Entry entry = (Map.Entry) iter.next();
                cmbLanguages.addItem(entry);
            }
        }
        cmbLanguages.repaint();
        cmbLanguages.updateUI();
    }

    public void setVisibilityOfTabs(boolean isAddVisible) {
        Component activeTab = null;
        Component removeTab = null;
        String title;
        if (!isAddVisible) {
            title = "Languages";
            activeTab = myTabs[0];
            removeTab = myTabs[1];
            loadLanguages();
        } else {
            title = "Add/Edit Language";
            activeTab = myTabs[1];
            removeTab = myTabs[0];
        }

        tabbedPaneLanguagesView.add(title, activeTab);
        tabbedPaneLanguagesView.remove(removeTab);
    }

    @Override
    public void modelPropertyChange(PropertyChangeEvent evt) {
        // System.out.println(evt.getPropertyName());
        if (evt.getPropertyName().equals(
                LanguageHandlerController.LANGUAGE_ADD_VISIBILITY)) {
            Boolean val = (Boolean) evt.getNewValue();
            setVisibilityOfTabs(val);

        } else if (evt.getPropertyName().equals(
                LanguageHandlerController.LANGUAGE_LOAD_VISIBILITY)) {
            Boolean val = (Boolean) evt.getNewValue();
            setVisibilityOfTabs(!val);
        } else if (evt.getPropertyName().equals(
                LanguageHandlerController.LANGUAGE_NAME)) {
            String val = evt.getNewValue().toString();
            txtLangName.setText(val);
        } else if (evt.getPropertyName().equals(
                LanguageHandlerController.DEVICE_ABSTRACTION_ID)) {

            Object key = evt.getNewValue();
            Iterator iter = hDeviceAbstractions.entrySet().
                    iterator();
            while (iter.hasNext()) {
                Map.Entry entry = (Map.Entry) iter.next();
                if (entry.getKey().toString().equals(key.toString())) {
                    cmbDeviceAbstractions.setSelectedItem(entry);
                    break;
                }
            }
        } else if (evt.getPropertyName().equals(
                LanguageHandlerController.SHOW_VIEW)) {

            this.centerParent();
        }
    }

    @Override
    public boolean validateForm() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
